package com.jphotomanager.io;

import java.awt.image.BufferedImage;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

import org.apache.log4j.Logger;

import com.openroom.model.Photograph;

public class ImageLock implements Lock {

    private static final Logger LOGGER = Logger.getLogger(ImageLock.class);
    private BufferedImage originalImage;

    private Photograph image;

    private boolean isLocked = false;

    public ImageLock(Photograph image) {
        super();
        this.image = image;
    }

    @Override
    public synchronized void lock() {
        while (isLocked) {
            try {
                wait();
            } catch (InterruptedException e) {
                LOGGER.error("error",e);
            }
        }
        isLocked = true;
    }

    @Override
    public void lockInterruptibly() throws InterruptedException {

    }

    @Override
    public boolean tryLock() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean tryLock(long time, TimeUnit unit)
            throws InterruptedException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public synchronized void unlock() {
        // TODO Auto-generated method stub

    }

    @Override
    public Condition newCondition() {
        // TODO Auto-generated method stub
        return null;
    }

}
